---
title: Button
description: A button or a component that looks like a button.
---

<ComponentPreview name="p-button-1" />

## Installation

<CodeTabs>

<TabsList>
  <TabsTab value="cli">CLI</TabsTab>
  <TabsTab value="manual">Manual</TabsTab>
</TabsList>
<TabsPanel value="cli">

```bash
npx shadcn@latest add @coss/button
```

</TabsPanel>

<TabsPanel value="manual">

<Steps>

<Step>Install the following dependencies:</Step>

```bash
npm install @base-ui-components/react
```

<Step>Import the following variables into your CSS file</Step>

```css
@theme inline {
  --color-destructive-foreground: var(--destructive-foreground);
}

:root {
  --destructive-foreground: var(--color-red-700);
}

.dark {
  --destructive-foreground: var(--color-red-400);
}
```

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="button" title="components/ui/button.tsx" />

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsPanel>

</CodeTabs>

## Usage

```tsx
import { Button } from "@/components/ui/button"
```

```tsx
<Button>Button</Button>
```

## Link

You can use the [`render`](https://base-ui.com/react/utils/use-render#migrating-from-radix-ui) prop to make another component look like a button. Here's an example of a link that looks like a button.

```tsx
import Link from "next/link"

import { Button } from "@/components/ui/button"

export function LinkAsButton() {
  return <Button render={<Link href="/login" />}>Login</Button>
}
```

## Examples

### Default

<ComponentPreview name="p-button-1" />

### Outline

<ComponentPreview name="p-button-2" />

### Secondary

<ComponentPreview name="p-button-3" />

### Destructive

<ComponentPreview name="p-button-4" />

### Destructive Outline

<ComponentPreview name="p-button-5" />

### Ghost

<ComponentPreview name="p-button-6" />

### Link

<ComponentPreview name="p-button-7" />

### Extra-small Size

<ComponentPreview name="p-button-8" />

### Small Size

<ComponentPreview name="p-button-9" />

### Large Size

<ComponentPreview name="p-button-10" />

### Extra-large Size

<ComponentPreview name="p-button-11" />

### Disabled

<ComponentPreview name="p-button-12" />

### Icon

<ComponentPreview name="p-button-13" />

### Icon Small Size

<ComponentPreview name="p-button-14" />

### Icon Large Size

<ComponentPreview name="p-button-15" />

### With Icon

<ComponentPreview name="p-button-16" />

### With Link

<ComponentPreview name="p-button-17" />

### Loading

<ComponentPreview name="p-button-18" />

## Comparing with Radix / shadcn

If you’re already familiar with Radix UI and shadcn/ui, this guide highlights the small differences and similarities so you can get started with **coss ui** quickly.

### Quick Checklist

- Replace `asChild` → `render` on `Button`

### Additional Notes

**Size Comparison**

**coss ui** button sizes are more compact compared to shadcn/ui, making them better suited for
dense applications. We also introduce new sizes (`xs`, `xl`, `icon-sm`, `icon-lg`) for more granular control:

| Size      | Height (shadcn/ui) | Height (coss ui) |
| --------- | ------------------ | ---------------- |
| `xs`      | -                  | 24px             |
| `sm`      | 32px               | 28px             |
| `default` | 36px               | 32px             |
| `lg`      | 40px               | 36px             |
| `xl`      | -                  | 40px             |
| `icon`    | 36px               | 32px             |
| `icon-sm` | -                  | 28px             |
| `icon-lg` | -                  | 36px             |

So, for example, if you were using the `default` size in shadcn/ui and you want to preserve the original height, you should use the `lg` size in coss ui.

**New Variants**

We've added a new `destructive-outline` variant for better UX patterns:

- **Primary actions**: Use `destructive` (solid red) for the main destructive action
- **Secondary triggers**: Use `destructive-outline` (outline red) to avoid alarming red buttons in the main interface

### Comparison Example

<span data-lib="radix-ui">
```tsx title="shadcn/ui"
// [!code word:asChild]
<Button asChild>
  <Link href="/login">Login</Link>
</Button>
```
</span>

<span data-lib="base-ui">
```tsx title="coss ui"
// [!code word:render]
<Button render={<Link href="/login" />}>Login</Button>
```
</span

>
